package com.xc.controller;

import com.xc.dto.ResultDTO;
import com.xc.entity.NavEntity;
import com.xc.entity.StudentEntity;
import com.xc.service.NavService;
import com.xc.service.StudentService;
import com.xc.util.Tool;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

//restful 增加post，修改put，删除delete，查询get
@RestController
@RequestMapping("/xc/nav")
@Api(tags = "导航管理")
public class NavController {
    @Autowired
    private NavService navService;

    @ApiOperation(value = "导航增加",notes = "导航增加接口的说明")
    @PostMapping()
    public ResultDTO add(@RequestBody NavEntity navEntity) {
        return navService.add(navEntity);
    }

    @ApiOperation("导航修改")
    @PutMapping()
    public ResultDTO update(@RequestBody NavEntity navEntity) {
        return navService.update(navEntity);
    }

    @ApiOperation("根据id进行删除导航数据")
    @DeleteMapping("/{id}")
    public ResultDTO delete(NavEntity navEntity) {
        return navService.delete(navEntity);
    }

    @ApiOperation("查询所有导航数据")
    @GetMapping()
    public ResultDTO findAll(NavEntity navEntity) {
        navEntity.setPage(Tool.strToPage(navEntity.getPage() + ""));
        navEntity.setLimit(Tool.strToLimit(navEntity.getLimit() + ""));
        return navService.findAll(navEntity);
    }

    @ApiOperation("根据id查询导航")
    @GetMapping("/{id}")
    public ResultDTO findById(NavEntity navEntity) {
        return navService.findById(navEntity);
    }

    @ApiOperation("查询导航总条数")
    @GetMapping("/count")
    public ResultDTO count(NavEntity navEntity) {
        return navService.count(navEntity);
    }
}
